package com.isunland.managesystem.entity;

import android.content.Context;
import com.isunland.managesystem.R;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import java.util.HashMap;

@SuppressWarnings({ "unused", "WeakerAccess" }) public class DataStatus {
  /** 销售订单 */
  public static final int KIND_ORDER = 1;
  public static final String NEW = "new";
  public static final String WAIT_CHECK = "waitCheck";
  public static final String CHECK_PASS = "checkPass";
  public static final String ABORT = "abort";
  @SuppressWarnings("WeakerAccess") public static final String ALL = "all";
  public static final String PUBLIS = "publish";
  public static final String SUBMIT = "submit";
  public static final String NEWBACK = "newback";
  public static final String ORGBACK = "orgback";
  public static final String ORGPUBLISH = "orgpublish";
  public static final String ORGUNITBACK = "orgunitback";
  public static final String ORUNITPUBLISH = "orunitpublish";
  public static final String PERSONCHECK = "personcheck";
  public static final String ARCHIVE = "archive";
  public static final String PAID = "checkPass01";//已支付
  public static final String DOCUMENT = "checkPass02";//已制单
  public static final String OUTSTOCK = "outStock";//已出库
  public static final String CANCEL = "cancel";//已作废
  public static final String WKZ = "WKZ";//未开展
  public static final String KZZ = "KZZ";//开展中
  public static final String YWC = "YWC";//已完成
  public static final String TRUE = "T";
  public static final String ORDER_CANCEL = "cancel";//已取消
  public static final String BACK_ORDER = "backOrder";//退订中
  public static final String BACK_ORDER_PUBLISH = "backOrderPublish";//退订完成
  public static final String CREATE = "create";//已办理租赁
  public static final String UNDEAL = "undeal";//未处理
  public static final String DEALING = "dealing";//处理中
  public static final String DEALED = "dealed";//已处理
  public static final String VISITED = "visited";//已回访
  public static final String REPLAY = "replay";//已回复
  public static final String ORDERED = "ordered";//已订购
  public static final String INSTOCK = "inStock";//已入库
  private static final String ERRORDATA = "error_data";//错数据
  /** 接单完成 */
  public static final String RECEIVE_PUBLISH = "receivePublish";
  /** 已有接单 */
  public static final String RECEIVE = "receive";
  public static HashMap<String, StatusProperty> map;

  static {

    map = new HashMap<>();
    map.put(ALL, new StatusProperty("全部", R.color.grey));
    map.put(ERRORDATA, new StatusProperty("错数据", R.color.black));

    map.put(NEW, new StatusProperty("草稿", R.color.red));
    map.put(UNDEAL, new StatusProperty("待处理", R.color.red));
    map.put(WAIT_CHECK, new StatusProperty("审核中", R.color.blue_textColor));
    map.put(DEALING, new StatusProperty("处理中", R.color.blue_textColor));
    map.put(CHECK_PASS, new StatusProperty("已审核", R.color.grey));
    map.put(ABORT, new StatusProperty("终止", R.color.yelloy_textColor));
    map.put(PUBLIS, new StatusProperty("已审核", android.R.color.darker_gray));
    map.put(DEALED, new StatusProperty("处理完毕", R.color.grey));
    map.put(VISITED, new StatusProperty("已回访", R.color.grey));
    map.put(SUBMIT, new StatusProperty("已提交", R.color.blue_textColor));
    map.put(NEWBACK, new StatusProperty("返回修改", R.color.yelloy_textColor));
    map.put(ORGBACK, new StatusProperty("部门返回", R.color.yelloy_textColor));
    map.put(ORGPUBLISH, new StatusProperty("部门通过", R.color.blue_textColor));
    map.put(ORGUNITBACK, new StatusProperty("单位返回", R.color.yelloy_textColor));
    map.put(ORUNITPUBLISH, new StatusProperty("单位通过", R.color.blue_textColor));
    map.put(PERSONCHECK, new StatusProperty("个人核查", R.color.blue_textColor));
    map.put(ARCHIVE, new StatusProperty("已归档", R.color.darkgray));
    map.put(PAID, new StatusProperty("已支付", R.color.darkgray));
    map.put(DOCUMENT, new StatusProperty("已制单", R.color.darkgray));
    map.put(OUTSTOCK, new StatusProperty("已出库", R.color.black, R.color.gray_dark));
    map.put(REPLAY, new StatusProperty("已回复", R.color.grey));
    map.put(ORDERED, new StatusProperty("已订购", R.color.grey));
    map.put(INSTOCK, new StatusProperty("已入库", R.color.grey));
    //订单
    map.put(OUTSTOCK, new StatusProperty("已派工", R.color.black, R.color.gray_dark));
    map.put(ORDER_CANCEL, new StatusProperty("已取消", R.color.grey));
    map.put(BACK_ORDER, new StatusProperty("退订中", R.color.blue_textColor));
    map.put(BACK_ORDER_PUBLISH, new StatusProperty("退订完成", R.color.grey));
    map.put(RECEIVE, new StatusProperty("已有接单", R.color.blue_textColor));
    map.put(RECEIVE_PUBLISH, new StatusProperty("接单完成", R.color.yelloy_textColor));
  }

  public static String getDataStatusName(String dataStatus) {
    return getDataStatusName(dataStatus, 0);
  }

  /** 某些地方,如订单,和其他地方的dataStutus标记相同,但是名称不一样.kind用于做区分 */
  public static String getDataStatusName(String dataStatus, int kind) {
    if (dataStatus == null) return "";
    if (!map.containsKey(dataStatus)) return "";
    if ((kind == KIND_ORDER) && MyStringUtil.equals(dataStatus, OUTSTOCK)) return "已出库";
    return map.get(dataStatus).getStatusName();
  }

  /** 某些地方,如订单,和其他地方的dataStutus标记相同,但是名称不一样.kind用于做区分 */
  public static int getDataStatusColor(Context context, String dataStatus, int kind) {
    if (dataStatus == null) return MyUtils.getColor(context, R.color.dark_grey);
    if (!map.containsKey(dataStatus)) return MyUtils.getColor(context, R.color.dark_grey);
    if ((kind == KIND_ORDER) && MyStringUtil.equals(dataStatus, OUTSTOCK)) {
      return MyUtils.getColor(context, R.color.black);
    }
    if ((kind == KIND_ORDER) && MyStringUtil.equals(dataStatus, CHECK_PASS)) {
      return MyUtils.getColor(context, android.R.color.darker_gray);
    }
    return MyUtils.getColor(context, map.get(dataStatus).getTextColor());
  }

  public static int getDataStatusColor(Context context, String dataStatus) {
    return getDataStatusColor(context, dataStatus, 0);
  }
}
